package com.qire.common.concurrent;

import java.util.concurrent.TimeUnit;

/**
 * 线程工具
 */
public class ThreadUtil {

    public static <T> IntervalRunWrapper<T> interval(long period, TimeUnit unit) {
        return new IntervalRunWrapper<T>(period, unit);
    }

    public static <T> OnceRunWrapper<T> once() {
        return new OnceRunWrapper<T>();
    }

    public static void post(Runnable runnable) {
        ((Scheduler.HandlerScheduler)Scheduler.Main).handler.post(runnable);
    }
    public static void post(Runnable runnable, long delayMillis) {
        ((Scheduler.HandlerScheduler)Scheduler.Main).handler.postDelayed(runnable, delayMillis);
    }

    public static void start(Runnable runnable) {
        new Thread(runnable).start();
    }
}
